<template>
  <div class="base-input-num">
    <!-- 递减按钮 -->
    <span role="button" class="base-input-num__decrease" @click="$emit('input', value - 1)"> - </span>
    <!-- 累加按钮 -->
    <span role="button" class="base-input-num__increase" @click="$emit('input', value + 1)"> + </span>
    <div class="base-input-content">
      <span class="base-input__inner">{{ value }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'BaseInputNum',
  props: {
    value: Number,
  },
}
</script>

<style scoped>
.base-input-num {
  position: relative;
  display: inline-block;
  width: 150px;
  line-height: 38px;
}

.base-input-num .base-input-content {
  display: block;
  position: relative;
  font-size: 14px;
  width: 100%;
}
.base-input-num .base-input__inner {
  -webkit-appearance: none;
  background-color: #fff;
  background-image: none;
  border-radius: 4px;
  border: 1px solid #dcdfe6;
  box-sizing: border-box;
  color: #606266;
  display: inline-block;
  font-size: inherit;
  height: 40px;
  line-height: 40px;
  outline: none;
  padding: 0 15px;
  transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  width: 100%;
  padding-left: 50px;
  padding-right: 50px;
  text-align: center;
}
.base-input-num .base-input-num__decrease,
.base-input-num .base-input-num__increase {
  position: absolute;
  z-index: 1;
  top: 1px;
  width: 40px;
  height: auto;
  text-align: center;
  background: #f5f7fa;
  color: #606266;
  cursor: pointer;
  font-size: 13px;
}
.base-input-num .base-input-num__decrease {
  left: 1px;
  border-radius: 4px 0 0 4px;
  border-right: 1px solid #dcdfe6;
}
.base-input-num .base-input-num__increase {
  right: 1px;
  border-radius: 0 4px 4px 0;
  border-left: 1px solid #dcdfe6;
}
</style>
